﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using FmcWebsite.Core;

namespace ContentManagementAdministrator
{
    public partial class FormMain : Form
    {
        private UserControl current_form = null;
        private const string title = "FMC Website Content Management Administrator";

        public FormMain()
        {
            InitializeComponent();

            DBConnect.UseMySql("localhost", "cms", "cmsuser", "cmsuser");

            buttonArticles.Tag = new UserControlArticles();
            buttonAuthors.Tag = new UserControlAuthor();
            buttonCategories.Tag = new UserControlCategories();

            TabButtonClick(buttonArticles, null);            
        }

        private void TabButtonClick(object sender, EventArgs e)
        {
            Button btn = (Button)sender;
            UserControl new_control = (UserControl)btn.Tag;

            if (current_form != new_control)
            {
                if (current_form !=null)
                    current_form.Parent = null;
                new_control.AutoSize = true;
                new_control.Parent = panelContent;
                current_form = new_control;
                current_form.Dock = DockStyle.Fill;
            }

            if (current_form is ITab)
            {
                this.Text = title + " - " + (current_form as ITab).GetTitle();
            }
            else
            {
                this.Text = title;
            }
        }
    }
}
